package org.example.myleet.p478;

import java.util.Random;

public class Solution {

    private double radius;

    private double xCenter;

    private double yCenter;

    private Random random;

    public Solution(double radius, double x_center, double y_center) {
        this.radius = radius;
        this.xCenter = x_center;
        this.yCenter = y_center;
        random = new Random(System.currentTimeMillis());
    }

    public double[] randPoint() {
        for (;;) {
            double xDelta = random.nextDouble() * (2 * radius) - radius;
            double yDelta = random.nextDouble() * (2 * radius) - radius;
            if (xDelta * xDelta + yDelta * yDelta <= radius * radius) {
                return new double[]{xCenter + xDelta, yCenter + yDelta};
            }
        }
    }
}
